package com.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.entity.SmsCouponCommodity;
import com.mall.mapper.SmsCouponCommodityMapper;
import com.mall.service.SmsCouponCommodityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SmsCouponCommodityServiceImpl extends ServiceImpl<SmsCouponCommodityMapper, SmsCouponCommodity> implements SmsCouponCommodityService {

    @Resource
    private SmsCouponCommodityMapper smsCouponCommodityMapper;

    @Override
    public SmsCouponCommodity getById(Integer id) {
        return smsCouponCommodityMapper.selectById(id);
    }

    @Override
    public List<SmsCouponCommodity> getAll() {
        return smsCouponCommodityMapper.selectList(null);
    }

    @Override
    public boolean deleteById(Integer id) {
        return smsCouponCommodityMapper.deleteById(id) > 0;
    }

    @Override
    public boolean save(SmsCouponCommodity smsCouponCommodity) {
        if(smsCouponCommodity.getId() == null)
        {
            return smsCouponCommodityMapper.insert(smsCouponCommodity) > 0;
        }else{
            return  smsCouponCommodityMapper.updateById(smsCouponCommodity) > 0;
        }
    }
}
